/**
 * \file Scripting.h
 * Ei4 lua scripting (Ei::Scripting) declarations.
 */
#ifndef EI_SCRIPTING_H
#define EI_SCRIPTING_H


extern "C"
{
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
}

#include <luabind/luabind.hpp>

#include <Ogre.h>

#include "include/TextureTest.h"

namespace Ei {

class Scripting {
        lua_State * mLua;
        Ogre::String mCfgDir;
public:
        Scripting(std::vector<const char*> script_names);
        ~Scripting();

        void load(const char * fname);
        void load(const Ogre::String& fname);
        void load(std::vector<const char*>& scripts);
        void exec(const Ogre::String& script);

        Ogre::String getDefaultsPath() { return mCfgDir + SLASH + "defaults.cfg"; }
        void saveDefaults(const char * scene_path);
        void loadDefaults();

        void saveTable(const char* table, std::ofstream& os);
        void saveString(const char* var, std::ofstream& os);

        Ogre::String toString(int idx, bool quote=false);
        Ogre::String escapeString(const Ogre::String& src);

        int getTableInt(const char * table, const char * name);
        float getTableFloat(const char * table, const char * name);
        double getTableDouble(const char * table, const char * name);
        bool getTableBool(const char * table, const char * name);
        const char* getTableCString(const char * table, const char * name);
        const char* getGlobalCString(const char * name);
        Ogre::Vector3 getTableVector3(const char * table, const char * name);
        void tableToPairs(const char * table, Ogre::NameValuePairList* pairs);
};

}

#endif
